**********************************************************************************
**********************************************************************************
** This code replicates all figures and tables in 								**
** "Do Corporations Retain Too Much Cash? Evidence from a Natural Experiment"	**
** by Hwanki Brian Kim, Woojin Kim, and Mathias Kronlund.						**
**																				**
** The provided data sets on which the code can run are pseudo data sets		**
** with random numbers that inherit the formats of the original data sets.		**
**********************************************************************************
**********************************************************************************


*******************************************************
*** Figure 1: Time-series Trends in Changes in Cash ***
*******************************************************
use pseudo_treated_matched_Figures, clear
bysort year treated: egen avg_cash_at_inc = mean(cash_at_inc)
bysort year treated: egen sd_cash_at_inc = sd(cash_at_inc)
bysort year treated: gen nobs = _N
duplicates drop year treated, force
keep treated year avg_cash_at_inc sd_cash_at_inc nobs
sort treated year


********************************************************************************
*** Figure 2: Time-series Trends in Payouts, Investments, and Wage Increases ***
********************************************************************************
// Panel A
use pseudo_treated_matched_Figures, clear
bysort year treated: egen avg_payout = mean(payout)
bysort year treated: egen sd_payout = sd(payout)
bysort year treated: gen nobs = _N
duplicates drop year treated, force
keep treated year avg_payout sd_payout nobs
sort treated year

// Panel B
use pseudo_treated_matched_Figures, clear
bysort year treated: egen avg_inv = mean(inv)
bysort year treated: egen sd_inv = sd(inv)
bysort year treated: gen nobs = _N
duplicates drop year treated, force
keep treated year avg_inv sd_inv nobs
sort treated year

// Panel C
use pseudo_treated_matched_Figures, clear
bysort year treated: egen avg_wage_inc = mean(wage_inc)
bysort year treated: egen sd_wage_inc = sd(wage_inc)
bysort year treated: gen nobs = _N
duplicates drop year treated, force
keep treated year avg_wage_inc sd_wage_inc nobs
sort treated year


***********************************
*** Table 1: Sample Composition ***
***********************************
use pseudo_panel_sample, clear
drop if missing(chaebol_2015) | missing(PICgte50)
duplicates drop firmid, force
// A1. All firms
tab PICgte50_flip chaebol_flip
// A2. Firms in [10B, 90B]
tab PICgte50_flip chaebol_flip if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
// A3. Public firms only
tab PICgte50_flip chaebol_flip if Public == 1

// B. Number of treated firms actually taxed (2015)
use pseudo_panel_sample, clear
drop if missing(chaebol_2015) | missing(PICgte50)
keep if treated == 1
keep if year == 2015
drop if missing(residual1) | missing(residual2)
gen taxed = cond(residual1>0 & residual2>0, 1, 0)
gen taxed_flip = cond(taxed == 0, 1, 0)
tab taxed_flip

// C. Preferred ex-post rule (2015)
gen ruleA = cond((residual1>0 & residual2>0 & residual1 < residual2) | (residual1<=0 & residual2>0), 1, 0)
gen ruleB = cond((residual1>0 & residual2>0 & residual2 < residual1) | (residual2<=0 & residual1>0), 1, 0)
gen ABindiff = cond(residual1<=0 & residual2<=0, 1, 0) 
count if ruleA == 1
count if ruleB == 1
count if ABindiff == 1


***********************************
*** Table 2: Summary Statistics ***
***********************************
use pseudo_panel_sample, clear
drop if missing(chaebol_2015) | missing(PICgte50)
replace sales_growth = sales_growth*100
tabstat treated after PICgte50 chaebol_2015 cash_at cash_at_inc lt_cash_inc payout div repurchase inv land_inc bldg_inc eqpt_inc wage_inc size lnS sales_growth ni2at ndi debt gindex, s(mean sd p1 p25 p50 p75 p99 n) col(stat)


******************************************
*** Table 3: Effects on Cash Retention ***
******************************************
// Panel A: Dependent variable = Delta(Cash + IVST)/assets
use pseudo_panel_sample, clear
// Columns (1)-(2): All firms
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)

// Panel B: Dependent variable = Delta(Cash + IVLT)/assets
use pseudo_panel_sample, clear
// Columns (1)-(2): All firms
reghdfe lt_cash_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe lt_cash_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe lt_cash_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe lt_cash_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
reghdfe lt_cash_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe lt_cash_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


**********************************
*** Table 4: Valuation Effects ***
**********************************
// Columns (1)-(2): All firms
use pseudo_panel_sample, clear
keep if year == 2014
reg CAR treated, robust
reghdfe CAR treated, absorb(i.ic) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reg CAR treated, robust
reghdfe CAR treated, absorb(i.ic) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
keep if year == 2014
reg CAR treated, robust
reghdfe CAR treated, absorb(i.ic) vce(cluster groupid)


******************************
*** Table 5: Value of Cash ***
******************************
use pseudo_FW_voc_sample, clear
drop if year == 2014| year == 2017 | year == 2018
// Column (1): All firms
reg excess_ret c.dCash##c.treated##c.after dEarn c.dEarn#c.treated c.dEarn#c.after c.dEarn#c.treated#c.after dNA c.dNA#c.treated c.dNA#c.after c.dNA#c.treated#c.after dRD c.dRD#c.treated c.dRD#c.after c.dRD#c.treated#c.after dDiv c.dDiv#c.treated c.dDiv#c.after c.dDiv#c.treated#c.after cash2cap_l1 c.cash2cap_l1#c.treated c.cash2cap_l1#c.after c.cash2cap_l1#c.treated#c.after debt_mkt c.debt_mkt#c.treated c.debt_mkt#c.after c.debt_mkt#c.treated#c.after c.cash2cap_l1#c.dCash c.cash2cap_l1#c.dCash#c.treated c.cash2cap_l1#c.dCash#c.after c.cash2cap_l1#c.dCash#c.treated#c.after c.debt_mkt#c.dCash c.debt_mkt#c.dCash#c.treated c.debt_mkt#c.dCash#c.after c.debt_mkt#c.dCash#c.treated#c.after, robust
// Column (2): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reg excess_ret c.dCash##c.treated##c.after dEarn c.dEarn#c.treated c.dEarn#c.after c.dEarn#c.treated#c.after dNA c.dNA#c.treated c.dNA#c.after c.dNA#c.treated#c.after dRD c.dRD#c.treated c.dRD#c.after c.dRD#c.treated#c.after dDiv c.dDiv#c.treated c.dDiv#c.after c.dDiv#c.treated#c.after cash2cap_l1 c.cash2cap_l1#c.treated c.cash2cap_l1#c.after c.cash2cap_l1#c.treated#c.after debt_mkt c.debt_mkt#c.treated c.debt_mkt#c.after c.debt_mkt#c.treated#c.after c.cash2cap_l1#c.dCash c.cash2cap_l1#c.dCash#c.treated c.cash2cap_l1#c.dCash#c.after c.cash2cap_l1#c.dCash#c.treated#c.after c.debt_mkt#c.dCash c.debt_mkt#c.dCash#c.treated c.debt_mkt#c.dCash#c.after c.debt_mkt#c.dCash#c.treated#c.after, robust
// Column (3): Matched sample
use pseudo_FW_voc_matched_sample, clear
reg excess_ret c.dCash##c.treated##c.after dEarn c.dEarn#c.treated c.dEarn#c.after c.dEarn#c.treated#c.after dNA c.dNA#c.treated c.dNA#c.after c.dNA#c.treated#c.after dRD c.dRD#c.treated c.dRD#c.after c.dRD#c.treated#c.after dDiv c.dDiv#c.treated c.dDiv#c.after c.dDiv#c.treated#c.after cash2cap_l1 c.cash2cap_l1#c.treated c.cash2cap_l1#c.after c.cash2cap_l1#c.treated#c.after debt_mkt c.debt_mkt#c.treated c.debt_mkt#c.after c.debt_mkt#c.treated#c.after c.cash2cap_l1#c.dCash c.cash2cap_l1#c.dCash#c.treated c.cash2cap_l1#c.dCash#c.after c.cash2cap_l1#c.dCash#c.treated#c.after c.debt_mkt#c.dCash c.debt_mkt#c.dCash#c.treated c.debt_mkt#c.dCash#c.after c.debt_mkt#c.dCash#c.treated#c.after, robust


**************************************************************************
*** Table 6: Alternative uses: Payouts, investment, and wage increases ***
**************************************************************************
/** Panel A: Payout **/
use pseudo_panel_sample, clear
// Columns (1)-(2): All firms
reghdfe payout i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe payout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe payout i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe payout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
reghdfe payout i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe payout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)

/** Panel B: Investment **/
use pseudo_panel_sample, clear
// Columns (1)-(2): All firms
reghdfe inv i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe inv i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe inv i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe inv i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
reghdfe inv i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe inv i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)

/** Panel C: Wage increase **/
use pseudo_panel_sample, clear
// Columns (1)-(2): All firms
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


**********************************************
*** Table 7: The role of behavioral biases ***
**********************************************
// Panel A: Firm responses and crisis memory
use pseudo_panel_sample, clear
reghdfe cash_at_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

// Panel B: Valuation effects and crisis memory
use pseudo_panel_sample, clear
keep if year == 2014
reg CAR i.treated##i.HitMoreByCrs, robust // Column (1)
reghdfe CAR i.treated##i.HitMoreByCrs, absorb(i.ic) vce(cluster groupid) // Column (2)


***************************************
*** Table 8: The role of governance ***
***************************************
// Panel A: Firm responses and crisis memory
use pseudo_panel_sample, clear
reghdfe cash_at_inc i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

/** Panel B: Valuation effects and crisis memory **/
use pseudo_panel_sample, clear
keep if year == 2014
reg CAR i.treated##i.HighGindex, robust // Column (1)
reghdfe CAR i.treated##i.HighGindex, absorb(i.ic) vce(cluster groupid) // Column (2)


***************************************
*** Table 9: Intensity of treatment ***
***************************************
// Panel A: Firm responses and crisis memory
use pseudo_panel_sample, clear
reghdfe cash_at_inc i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

/** Panel B: Valuation effects and crisis memory **/
use pseudo_panel_sample, clear
keep if year == 2014
reg CAR i.treated##i.HighNI2013, robust // Column (1)
reghdfe CAR i.treated##i.HighNI2013, absorb(i.ic) vce(cluster groupid) // Column (2)


****************************
*** Table 10: Pre-trends ***
****************************
// Panel A: All firms
use pseudo_panel_sample, clear
keep if year == 2014
** Columns (1)-(2): Cash retention
reg avg_cash_buildup_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_cash_buildup_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)
** Columns (3)-(4): Payout
reg avg_payout_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_payout_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)
** Columns (5)-(6): Investment
reg avg_inv_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_inv_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)
** Columns (7)-(8): Wage increases
reg avg_wage_change_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_wage_change_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)

// Panel B: Firms in [10B, 90B]
use pseudo_panel_sample, clear
keep if year == 2014
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
** Columns (1)-(2): Cash retention
reg avg_cash_buildup_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_cash_buildup_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)
** Columns (3)-(4): Payout
reg avg_payout_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_payout_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)
** Columns (5)-(6): Investment
reg avg_inv_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_inv_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)
** Columns (7)-(8): Wage increases
reg avg_wage_change_inc treated lnS sales_growth ni2at debt, robust
reghdfe avg_wage_change_inc treated lnS sales_growth ni2at debt, absorb(i.ic) vce(cluster groupid)


*************************************************************
*** Table 11: Robustness: Placebo and additional controls ***
*************************************************************
// Panel A: Non-chaebol firms in [10B, 90B]
use pseudo_panel_sample, clear
drop if chaebol_2015 == 1
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe payout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe inv i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)

// Panel B: Placebo, chaebol firms in [10B, 90B]
use pseudo_panel_sample, clear
drop if chaebol_2015 == 0
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
replace treated = PICgte50
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe payout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe inv i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)

// Panel C: Additional control variables
use pseudo_panel_sample, clear
reghdfe cash_at_inc c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe payout c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe inv c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe wage_inc c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)






*****************************************************************************************
********************************** Internet Appendix ************************************
*****************************************************************************************

*******************************************************************
*** Table A1: Comparison of matched treated and untreated firms ***
*******************************************************************
use pseudo_treated_matched_sample, clear
replace sales_growth = sales_growth*100
mat T = J(11, 4, .)
loc i = 1
// Means
foreach xvar in cash_at cash_at_inc payout inv wage_inc lnS sales_growth ni2at debt ndi size{
	qui ttest `xvar', by(treated) unequal
	qui mat T[`i',1] = r(mu_2)
	qui mat T[`i',2] = r(mu_1)
	qui mat T[`i',3] = r(mu_2) - r(mu_1)
	qui mat T[`i',4] = -r(t)
	loc i = `i' + 1
}
mat rownames T = cash_at cash_at_inc payout wage_inc inv lnS sales_growth ni2at debt ndi size
frmttable using ttest_2013_match.doc, statmat(T) sdec(3,3,3,2) replace ctitle("", "Treated", "Untreated", "Difference", "t-stat")


*****************************************************************
*** Table A2: Summary statistics: Public versus private firms ***
*****************************************************************
use pseudo_panel_sample, clear
drop if missing(chaebol_2015) | missing(PICgte50)
replace sales_growth = sales_growth*100
tabstat treated after PICgte50 chaebol_2015 cash_at cash_at_inc lt_cash_inc payout div repurchase inv land_inc bldg_inc eqpt_inc wage_inc size lnS sales_growth ni2at ndi debt gindex if Public == 1, s(mean sd p1 p25 p50 p75 p99 n) col(stat)
tabstat treated after PICgte50 chaebol_2015 cash_at cash_at_inc lt_cash_inc payout div repurchase inv land_inc bldg_inc eqpt_inc wage_inc size lnS sales_growth ni2at ndi debt if Public == 0, s(mean sd p1 p25 p50 p75 p99 n) col(stat)


********************************************************
*** Table A4: Valuation Effects - Portfolio Approach ***
********************************************************
// Column (1): All firms - Long-short portfolio - CAR for treated - nontreated
use pseudo_portfolio_sample, clear
gen d_event = cond(year == 2014 & ((month == 8 & (day == 6 | day == 7 | day == 8)) | (month == 12 & (day == 2 | day == 3 | day == 4))), 1, 0)
gen d_event1 = cond(year == 2014 & month == 8 & (day == 6 | day == 7 | day == 8), 1, 0)
gen d_event2 = cond(year == 2014 & month == 12 & (day == 2 | day == 3 | day == 4), 1, 0)
replace d_event1 = . if d_event2==1
replace d_event2 = . if d_event1==1
winsor2 ret_d, replace by(date)
collapse (mean) ret_d (first) d_event* ret_mkt rf, by(date treated)
reshape wide ret_d, i(date) j(treated)
gen ret_longshort = ret_d1 - ret_d0
gen excess_mret = ret_mkt - rf
gen ret_d1_ex = ret_d1 - rf
gen ret_d0_ex = ret_d0 - rf
reg ret_d1_ex excess_mret d_event, robust
reg ret_d0_ex excess_mret d_event, robust
reg ret_longshort excess_mret d_event, robust
reg ret_d1_ex excess_mret d_event1, robust
reg ret_d0_ex excess_mret d_event1, robust
reg ret_longshort excess_mret d_event1, robust
reg ret_d1_ex excess_mret d_event2, robust
reg ret_d0_ex excess_mret d_event2, robust
reg ret_longshort excess_mret d_event2, robust

// Column (2): All firms - Long-short portfolio - CAR for treated - nontreated (industry first)
use pseudo_portfolio_sample, clear
gen d_event = cond(year == 2014 & ((month == 8 & (day == 6 | day == 7 | day == 8)) | (month == 12 & (day == 2 | day == 3 | day == 4))), 1, 0)
gen d_event1 = cond(year == 2014 & month == 8 & (day == 6 | day == 7 | day == 8), 1, 0)
gen d_event2 = cond(year == 2014 & month == 12 & (day == 2 | day == 3 | day == 4), 1, 0)
replace d_event1 = . if d_event2==1
replace d_event2 = . if d_event1==1
collapse (mean) ret_d (first) d_event* ret_mkt rf, by(ic date treated)
bys ic date: egen count = count(ret_d)
drop if count!=2
collapse (mean) ret_d (first) d_event* ret_mkt rf, by(date treated)
reshape wide ret_d, i(date) j(treated)
gen ret_longshort = ret_d1 - ret_d0
gen excess_mret = ret_mkt - rf
gen ret_d1_ex = ret_d1 - rf
gen ret_d0_ex = ret_d0 - rf
reg ret_d1_ex excess_mret d_event, robust
reg ret_d0_ex excess_mret d_event, robust
reg ret_longshort excess_mret d_event, robust
reg ret_d1_ex excess_mret d_event1, robust
reg ret_d0_ex excess_mret d_event1, robust
reg ret_longshort excess_mret d_event1, robust
reg ret_d1_ex excess_mret d_event2, robust
reg ret_d0_ex excess_mret d_event2, robust
reg ret_longshort excess_mret d_event2, robust

// Column (3): Firms in [10B, 90B] - Long-short portfolio - CAR for treated - nontreated
use pseudo_portfolio_sample, clear
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
gen d_event = cond(year == 2014 & ((month == 8 & (day == 6 | day == 7 | day == 8)) | (month == 12 & (day == 2 | day == 3 | day == 4))), 1, 0)
gen d_event1 = cond(year == 2014 & month == 8 & (day == 6 | day == 7 | day == 8), 1, 0)
gen d_event2 = cond(year == 2014 & month == 12 & (day == 2 | day == 3 | day == 4), 1, 0)
replace d_event1 = . if d_event2==1
replace d_event2 = . if d_event1==1
winsor2 ret_d, replace by(date)
collapse (mean) ret_d (first) d_event* ret_mkt rf, by(date treated)
reshape wide ret_d, i(date) j(treated)
gen ret_longshort = ret_d1 - ret_d0
gen excess_mret = ret_mkt - rf
gen ret_d1_ex = ret_d1 - rf
gen ret_d0_ex = ret_d0 - rf
reg ret_d1_ex excess_mret d_event, robust
reg ret_d0_ex excess_mret d_event, robust
reg ret_longshort excess_mret d_event, robust
reg ret_d1_ex excess_mret d_event1, robust
reg ret_d0_ex excess_mret d_event1, robust
reg ret_longshort excess_mret d_event1, robust
reg ret_d1_ex excess_mret d_event2, robust
reg ret_d0_ex excess_mret d_event2, robust
reg ret_longshort excess_mret d_event2, robust

// Column (4): Firms in [10B, 90B] - Long-short portfolio - CAR for treated - nontreated (industry first)
use pseudo_portfolio_sample, clear
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
gen d_event = cond(year == 2014 & ((month == 8 & (day == 6 | day == 7 | day == 8)) | (month == 12 & (day == 2 | day == 3 | day == 4))), 1, 0)
gen d_event1 = cond(year == 2014 & month == 8 & (day == 6 | day == 7 | day == 8), 1, 0)
gen d_event2 = cond(year == 2014 & month == 12 & (day == 2 | day == 3 | day == 4), 1, 0)
replace d_event1 = . if d_event2==1
replace d_event2 = . if d_event1==1
collapse (mean) ret_d (first) d_event* ret_mkt rf, by(ic date treated)
bys ic date: egen count = count(ret_d)
drop if count!=2
collapse (mean) ret_d (first) d_event* ret_mkt rf, by(date treated)
reshape wide ret_d, i(date) j(treated)
gen ret_longshort = ret_d1 - ret_d0
gen excess_mret = ret_mkt - rf
gen ret_d1_ex = ret_d1 - rf
gen ret_d0_ex = ret_d0 - rf
reg ret_d1_ex excess_mret d_event, robust
reg ret_d0_ex excess_mret d_event, robust
reg ret_longshort excess_mret d_event, robust
reg ret_d1_ex excess_mret d_event1, robust
reg ret_d0_ex excess_mret d_event1, robust
reg ret_longshort excess_mret d_event1, robust
reg ret_d1_ex excess_mret d_event2, robust
reg ret_d0_ex excess_mret d_event2, robust
reg ret_longshort excess_mret d_event2, robust


***********************************
*** Table A5: Payout components ***
***********************************
use pseudo_panel_sample, clear
// Columns (1)-(2): Dividends
reghdfe div i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe div i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Repurchases
reghdfe repurchase i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe repurchase i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Paid out
gen paidout = cond(!missing(payout), cond(payout != 0, 1, 0), .)
reghdfe paidout i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe paidout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


***************************************
*** Table A6: Investment components ***
***************************************
use pseudo_panel_sample, clear
// Columns (1)-(2): Investment in land
reghdfe land_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe land_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Investment in buildings
reghdfe bldg_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe bldg_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Investment in equipment
reghdfe eqpt_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe eqpt_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


***********************************************
*** Table A7: Rule A vs. Rule B: Investment ***
***********************************************
use pseudo_panel_sample, clear
/* Create a dummy for whether the firm is better off ex-post with Rule A */
preserve
keep if treated == 1
keep if year == 2015
drop if missing(residual1) | missing(residual2)
gen ruleA = cond((residual1>0 & residual2>0 & residual1 < residual2) | (residual1<=0 & residual2>0), 1, 0)
keep firmid ruleA
save ruleA, replace
restore
joinby firmid using ruleA, unm(m)
keep if treated == 1
// Column (1)
reghdfe inv i.ruleA##i.after, absorb(i.firmid i.year) vce(cluster groupid)
// Column (2)
reghdfe inv i.ruleA##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


**********************************************************
*** Table A8: Average wages versus number of employees ***
**********************************************************
use pseudo_panel_sample, clear
replace nempl_at = nempl_at*1000000
/** Panel A: All firms **/
// Columns (1)-(2): Wage per employee
reghdfe lnwage_per_cap i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe lnwage_per_cap i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Number of employees
reghdfe no_empl i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe no_empl i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Number of employees/assets
reghdfe nempl_at i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe nempl_at i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)

/** Panel B: Firms in [10B, 90B] **/
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
// Columns (1)-(2): Wage per employee
reghdfe lnwage_per_cap i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe lnwage_per_cap i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Number of employees
reghdfe no_empl i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe no_empl i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Number of employees/assets
reghdfe nempl_at i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe nempl_at i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


********************************
*** Table A9: Debt financing ***
********************************
use pseudo_panel_sample, clear
// Columns (1)-(2): All firms
reghdfe ndi i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe ndi i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe ndi i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe ndi i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
reghdfe ndi i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid)
reghdfe ndi i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


************************************************************************
*** Table A10: Crisis memory, governance, and pre-reform cash levels ***
************************************************************************
// Panel A: Crisis memory and pre-reform cash
use pseudo_panel_sample, clear
keep if year == 2013
reg cash_at HitMoreByCrs size cf, robust

// Panel B: Governance and pre-reform cash
reg cash_at HighGindex size cf, robust


*************************************************************
*** Table A11: Placebo tests on the role of crisis memory ***
*************************************************************
use pseudo_panel_sample, clear
// Panel A: High external finance dependence without past crisis experience
drop if missing(EstB4Crs)
keep if EstB4Crs == 0
reghdfe cash_at_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe payout i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe inv i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe wage_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)

// Panel B: Past crisis experience and low external finance dependence
use pseudo_panel_sample, clear
reghdfe cash_at_inc i.treated##i.after##i.HitLessByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe payout i.treated##i.after##i.HitLessByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe inv i.treated##i.after##i.HitLessByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
reghdfe wage_inc i.treated##i.after##i.HitLessByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


***********************************************
*** Table A12: Governance and profitability ***
***********************************************
// Panel A: Governance, investment, and changes in profitability
use pseudo_panel_sample, clear
keep if treated == 1
keep if year == 2015
reg ROIC_growth c.inv##c.HighGindex, robust
reghdfe ROIC_growth c.inv##c.HighGindex, absorb(i.ic) vce(cluster groupid)

// Panel B: Governance, industry profitability, and investment changes
use pseudo_panel_sample, clear
duplicates drop firmid, force
keep if treated == 1
egen medG_treated = median(gindex)
gen HighGindex_treat = cond(!missing(gindex), cond(gindex > medG_treated, 1, 0), .)
reg inv_raise c.indROIC_post##c.HighGindex_treat, robust
reg payout_raise c.indROIC_post##c.HighGindex_treat, robust


*************************************************************
*** Table A13: Valuation effects: Excluding chaebol firms ***
*************************************************************
// Columns (1)-(2): All firms
use pseudo_panel_sample, clear
keep if year == 2014
drop if chaebol_2015 == 1
reg CAR treated, robust
reghdfe CAR treated, absorb(i.ic) vce(cluster groupid)
// Columns (3)-(4): Firms in [10B, 90B]
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reg CAR treated, robust
reghdfe CAR treated, absorb(i.ic) vce(cluster groupid)
// Columns (5)-(6): Matched sample
use pseudo_treated_matched_sample, clear
keep if year == 2014
drop if chaebol_2015 == 1
reg CAR treated, robust
reghdfe CAR treated, absorb(i.ic) vce(cluster groupid)


*******************************************************************
*** Table A14: Robustness: Controlling for firm characteristics ***
*******************************************************************
use pseudo_panel_sample, clear
// Column (1)
reghdfe cash_at_inc c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Column (2)
reghdfe payout c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Column (3)
reghdfe inv c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)
// Column (4)
reghdfe wage_inc c.treated##c.after dist lnS sales_growth ni2at debt c.dist#c.after c.lnS#c.after c.sales_growth#c.after c.ni2at#c.after c.debt#c.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid)


********************************************
** Table A15: Donut discontinuity sample ***
********************************************
// Panel A: All firms in [10B, 45B) U (55B, 90B]
use pseudo_panel_sample, clear
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
drop if equity_2015 >= 45000000000 & equity_2015 <= 55000000000
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (1)
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe payout i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (3)
reghdfe payout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)
reghdfe inv i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (5)
reghdfe inv i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (6)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (7)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (8)


// Panel B: Non-chaebol firms in [10B, 45B) U (55B, 90B]
use pseudo_panel_sample, clear
drop if chaebol_2015 == 1
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
drop if equity_2015 >= 45000000000 & equity_2015 <= 55000000000
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (1)
reghdfe cash_at_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe payout i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (3)
reghdfe payout i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)
reghdfe inv i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (5)
reghdfe inv i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (6)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.year) vce(cluster groupid) // Column (7)
reghdfe wage_inc i.treated##i.after, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (8)


*********************************************************************
*** Table A16: The role of behavioral biases: The narrower sample ***
*********************************************************************
// Panel A: Firm responses and crisis memory
use pseudo_panel_sample, clear
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe cash_at_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

// Panel B: Valuation effects and crisis memory
use pseudo_panel_sample, clear
keep if year == 2014
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reg CAR c.treated##c.HitMoreByCrs, robust // Column (1)
reghdfe CAR c.treated##c.HitMoreByCrs, absorb(i.ic) vce(cluster groupid) // Column (2)


**************************************************************
*** Table A17: Intensity of treatment: The narrower sample ***
**************************************************************
// Panel A: Firm responses and treatment intensity
use pseudo_panel_sample, clear
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reghdfe cash_at_inc i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

// Panel B: Valuation effects and treatment intensity
use pseudo_panel_sample, clear
keep if year == 2014
keep if equity_2015 >= 10000000000 & equity_2015 <= 90000000000
reg CAR c.treated##c.HighNI2013, robust // Column (1)
reghdfe CAR c.treated##c.HighNI2013, absorb(i.ic) vce(cluster groupid) // Column (2)


********************************************************************
*** Table A18: The role of behavioral biases: The matched sample ***
********************************************************************
// Panel A: Firm responses and crisis memory
use pseudo_treated_matched_sample, clear
reghdfe cash_at_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HitMoreByCrs, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

// Panel B: Valuation effects and crisis memory
use pseudo_treated_matched_sample, clear
keep if year == 2014
reg CAR c.treated##c.HitMoreByCrs, robust // Column (1)
reghdfe CAR c.treated##c.HitMoreByCrs, absorb(i.ic) vce(cluster groupid) // Column (2)


*************************************************************
*** Table A19: The role of governance: The matched sample ***
*************************************************************
// Panel A: Firm responses and governance
use pseudo_treated_matched_sample, clear
reghdfe cash_at_inc i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HighGindex, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

// Panel B: Valuation effects and governance
use pseudo_treated_matched_sample, clear
keep if year == 2014
reg CAR c.treated##c.HighGindex, robust // Column (1)
reghdfe CAR c.treated##c.HighGindex, absorb(i.ic) vce(cluster groupid) // Column (2)


*************************************************************
*** Table A20: Intensity of treatment: The matched sample ***
*************************************************************
// Panel A: Firm responses and treatment intensity
use pseudo_treated_matched_sample, clear
reghdfe cash_at_inc i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (1)
reghdfe payout i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (2)
reghdfe inv i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (3)
reghdfe wage_inc i.treated##i.after##i.HighNI2013, absorb(i.firmid i.ic#i.year) vce(cluster groupid) // Column (4)

// Panel B: Valuation effects and treatment intensity
use pseudo_treated_matched_sample, clear
keep if year == 2014
reg CAR c.treated##c.HighNI2013, robust // Column (1)
reghdfe CAR c.treated##c.HighNI2013, absorb(i.ic) vce(cluster groupid) // Column (2)
